﻿<ng-include src="'./includes/header.html'"></ng-include>

<div class="main">
    <div class="container">
      <div class="row">
      		<div class="widget stacked">	
				<div class="widget-header">
					<i class="icon-bookmark"></i>
					<h3>{{ 'SHORTCUTS' | i18n }}</h3>
				</div> <!-- /widget-header -->
				<div class="widget-content">
					<div class="shortcuts">
                        <a ng-click="vm.refresh()" class="shortcut">
                            <i class="shortcut-icon icon-refresh"></i>
                            <span class="shortcut-label">{{ 'REFRESH' | i18n }}</span>
                        </a>
					</div> <!-- /shortcuts -->	
				</div> <!-- /widget-content -->
			</div> <!-- /widget -->
		</div>
        <div class="row" ng-show="server != null && server.server_id != null && server.server_id > 0">
            <div class="widget stacked">
                <div class="widget-header">
                    <i class="icon-bookmark"></i>
                    <h3>{{ 'SERVER' | i18n }}</h3>
                </div> <!-- /widget-header -->
                <div class="widget-content">
                    <table class="table table-striped table-bordered">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>{{ 'NAME' | i18n }}</th>
                                <th>{{ 'STATUS' | i18n }}</th>
                                <th>{{ 'LASTDATETIME' | i18n }}</th>
                                <th class="td-actions">{{ 'ACTIONS' | i18n }}</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>{{server.server_id}}</td>
                                <td>{{server.name}}</td>
                                <td>
                                    <span ng-show="server.is_started" class="label label-success"><span class="icon icon-refresh">  {{ 'RUNNING' | i18n }}</span></span>
                                    <span ng-show="server.is_stopped" class="label label-info"><span class="icon icon-stop">  {{ 'STOPPED' | i18n }}</span></span>
                                    <span ng-show="server.is_updating" class="label label-important"><span class="icon icon-wrench">  {{ 'UPDATING' | i18n }}</span></span>
                                    <span ng-show="server.is_stopping" class="label label-warning"><span class="icon icon-arrow-down">  {{ 'STOPPING' | i18n }}</span></span>
                                    <span ng-show="server.is_starting" class="label label-warning"><span class="icon icon-arrow-up">  {{ 'STARTING' | i18n }}</span></span>
                               </td>
                                <td>{{server.last_datetime}}</td>
                                <td><a href="#/server/{{server.server_id}}" class="btn btn-info btn-lg btn-block" role="button"><span>{{ 'MANAGE' | i18n }}</span></a></td>
                            </tr>
                        </tbody>
                    </table>
                </div> <!-- /widget-content -->
            </div> <!-- /widget -->
        </div>
		<div class="row">
      		<div class="widget stacked widget-table action-table">
					
				<div class="widget-header">
					<i class="icon-th-list"></i>
					<h3>{{ 'ACTIONS' | i18n }}</h3>
				</div> <!-- /widget-header -->
				<div class="widget-content">
					<table class="table table-striped table-bordered">
						<thead>
							<tr>
								<th>#</th>
								<th>{{ 'SERVER' | i18n }}</th>
								<th>{{ 'USER' | i18n }}</th>
								<th>{{ 'ACTION' | i18n }}</th>
								<th>{{ 'CREATEDAT' | i18n }}</th>
								<th>{{ 'STATUT' | i18n }}</th>
								<th>{{ 'EXECUTEDENDED' | i18n }}</th>
                                <th></th>
							</tr>
						</thead>
						<tbody>
							<tr ng-repeat="action in actions" ng-class="{active:action.is_processing, success : action.is_success, danger:(action.is_executed && !action.is_success)}">
									<td>{{ action.action_id }}</td>
									<td><a ng-href="#/server/{{ action.server_id }}" class="btn btn-xs btn-block active" role="button">{{ action.server_id }}</a></td>
									<td>
										<span ng-bind="action.user_name"></span>
										<span ng-show="!action.user_name" ng-bind="action.user_id"></span>
									</td>
									<td>{{ action.action }}</td>
									<td>{{ action.action_datetime }}</td>
									<td>{{ action.status }}</td>
									<td><span ng-show="action.is_processing" ng-bind="action.start_datetime"></span><span ng-show="action.is_executed" ng-bind="action.end_datetime"></span></td>
                                    <td><a class="btn btn-danger" ng-show="user.role >= 8 && !action.is_executed" ng-click="vm.closeAction(action)"><span class="icon-remove"></span></a></td>
								</tr>
						</tbody>
					</table>
				</div> <!-- /widget-content -->
			</div>
		</div>
	</div>
</div>
